$(function () {
    $('#login').on('click', function () {
        const username = $("#username").val().trim()
        const password = $('#password').val().trim()
        if (!username || !password) {
            layer.msg('密码或用户名不能为空', function (res) {
                return
            })
        }
        $.post(
            'http://localhost:8080/api/v1/admin/user/login',
            {
                username, password
            },

            function (res) {
                if (res.code !== 200) {
                    console.log(res)
                    layer.msg(res.msg)
                    return
                }
                localStorage.setItem('token', res.token)
                location.href = '../../index.html'
            }
        )
    })
})